package com.auth.manage.user.domain.entity;

import com.auth.manage.common.user.api.constant.UserPermission;
import com.auth.manage.common.user.api.constant.UserRole;
import com.auth.manage.common.user.api.constant.UserStatus;
import com.auth.manage.datasource.domain.entity.BaseEntity;
import com.auth.manage.user.infra.mapper.HashPwdTypeHandler;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

@Data
@TableName("user") // 映射数据库表名
public class User extends BaseEntity {

    private String telephone;

    private String inviteCode;

    private Long inviterId;

    private String nickName;

    @TableField(typeHandler = HashPwdTypeHandler.class)
    private String passwordHash;

    private String email;


    private UserRole userRole;
    private UserPermission userPermission;
    private UserStatus userStatus;

    public void register(String telephone, String randomGenerateInviteCode, String userName, Long inviterId,String pwd) {
        this.telephone = telephone;
        this.inviteCode = randomGenerateInviteCode;
        this.nickName = userName;
        this.inviterId = inviterId;
        this.passwordHash = pwd;
    }
}